package com.clstu.practice;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class TestKeyListener extends JFrame {
    public static void main(String[] args) {
            new TestKeyListener();
    }
    public TestKeyListener(){
        super("测试键盘监听器");
        this.setSize(500,500);
        this.setLocation(500,300);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.addKeyListener(new KeyListener() {
            @Override
            public void keyTyped(KeyEvent e) {

            }

            @Override
            public void keyPressed(KeyEvent e) {
                System.out.println("hello");
            }

            @Override
            public void keyReleased(KeyEvent e) {

            }
        });
    }
}
